package com.oyo.common.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.ToString;

import java.util.Arrays;

/**
 * 预订规则
 */
@Getter
@ToString
@RequiredArgsConstructor
public enum BookingRule {
    MULTIPLE(1, "多间预订"),
    CONTINUOUS(2, "连住预定"),
    ADVANCE(3, "提前预定");
    private final Integer code;
    private final String name;

    public static BookingRule parse(Integer code) {
        return Arrays.stream(values()).filter(item -> item.code.equals(code))
                .findFirst().orElse(null);
    }
}
